﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IP.Core.IPData;
using IP.Core.IPUserService;
using BKIDS.CDBNames;
using IP.Core.IPCommon;
public partial class DanhMuc_F100_Tu_dien : System.Web.UI.Page
{
    #region Members
    US_CM_DM_TU_DIEN m_us_dm_tu_dien = new US_CM_DM_TU_DIEN();
    DS_CM_DM_TU_DIEN m_ds_dm_tu_dien = new DS_CM_DM_TU_DIEN();
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!this.IsPostBack)
            {
                load_data_2_combo_loai_tu_dien();
                load_data_2_grid();
            }

        }
        catch (Exception v_e)
        {
            this.Response.Write(v_e.ToString());
        }

    }
    #region Load từ điển dựa vào loại từ điển từ combobox
    private void load_data_2_grid()
    {
        // phải có dấu cách trước where
        m_us_dm_tu_dien.FillDataset(m_ds_dm_tu_dien, " WHERE ID_LOAI_TU_DIEN =" + CIPConvert.ToDecimal(m_cbo_loai_td_grv.SelectedValue));
        m_grv_cm_dm_tu_dien.DataSource = m_ds_dm_tu_dien.CM_DM_TU_DIEN;
        m_grv_cm_dm_tu_dien.DataBind();
    }
    //Load dữ liệu lên combobox loại từ điển
    private void load_data_2_combo_loai_tu_dien()
    {
        US_CM_DM_LOAI_TD v_us_cm_dm_loai_td = new US_CM_DM_LOAI_TD();
        DS_CM_DM_LOAI_TD v_ds_cm_dm_loai_td = new DS_CM_DM_LOAI_TD();

        v_us_cm_dm_loai_td.FillDataset(v_ds_cm_dm_loai_td);

        m_cbo_loai_td_grv.DataTextField = CM_DM_LOAI_TD.TEN_LOAI;
        m_cbo_loai_td_grv.DataValueField = CM_DM_LOAI_TD.ID;

        m_cbo_loai_td_grv.DataSource = v_ds_cm_dm_loai_td.CM_DM_LOAI_TD;
        m_cbo_loai_td_grv.DataBind();

    }
    protected void m_cbo_loai_td_grv_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            load_data_2_grid();
        }
        catch (Exception v_e)
        {
            this.Response.Write(v_e.ToString());
        }
    }
    #endregion

}